package org.example.controller;

import org.example.config.BeanConfig;
import org.example.service.AccountService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AccountController {
    public static void main(String[] args) {
        // 用main方法模拟controller
        // 使用配置方式开启事务
        //ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");

        // 使用注解方式开启事务
        ApplicationContext context = new AnnotationConfigApplicationContext(BeanConfig.class);
        AccountService accountService = (AccountService) context.getBean("accountService");
        accountService.transfer("zhangsan","lisi",500F);
    }
}
